using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Runtime.InteropServices;
using System.Net;

namespace MiddlewareServer
{
    [StructLayout(LayoutKind.Sequential, Size = 8)]
    internal struct HeaderStruct
    {
        public uint msgType;
        public int msgLength;
    }

    [StructLayout(LayoutKind.Sequential, Size = 16)]
    internal struct ShootStruct
    {
        public HeaderStruct header;
        public uint shootX;
        public uint shootY;

        //Example for const byte arrays:
        //[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        //public byte[] mode;    // file mode
    }

    [StructLayout(LayoutKind.Sequential, Size = 20)]
    internal struct ShootResStruct
    {
        public HeaderStruct header;
        public uint shootX;
        public uint shootY;
        public uint shootCnt;
    }

    public enum eReturnErrorCode
    {
        Success = 0,
        Timeout,
        Client_not_available,
        Server_not_available,
        Incorect_data
    }

    public interface IServer_rpt
    {
        void connect(IPAddress ip);
        void ready(uint a_uiClientID, DataTable a_dtShipsTable);
        void shoot(uint a_uiClientID, uint a_uiXPos, uint a_uiYPos);
        void disconnect(IPAddress ip);
    }

    public interface IServer_cmd
    {
        void readyResult(uint a_uiClientID, eReturnErrorCode a_eRetCode);
        void shootResult(uint a_uiClientID, uint a_uiXPos, uint a_uiYPos, uint a_uiShooted);
        void disconnectResult(eReturnErrorCode a_eRetCode);
        void connectResult(eReturnErrorCode a_eRetCode);
    }
}
